// xc_lshop/shop/deposit/com/qrcode.js
var actdepositbill = require('../../model/deposit_bill')

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    isback:Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {
    show:false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    init(op,obj){ //op 1存 2取 id核销订单id
      var cop= op;
      var id=obj['id']
      var uid=obj['uid']
      this.setData({
        uid:uid
      })
      var that = this;
      actdepositbill.getqrcode(cop,id,uid).then(function (res) {
        if (res["status"] == 1) {
         
          console.log(res)
          that.setData({
            qrcode:res.url,
            show:true
          })
          
        } else {
          wx.showModal({
            title: '错误',
            content: res["message"],
            success(res){
              that.onClose()
            }
          })
          
        }
      })
    },
    onClose(){
      this.setData({
        show:false
      })
      if(this.data.isback){
        wx.redirectTo({
          url:  '/xc_lshop/shop/deposit/record/access?uid='+this.data.uid,
        })
      }
      
    }
  }
})
